package com.contract.spirit.ui

import androidx.lifecycle.MutableLiveData
import com.contract.commonlib.http.status.ResultState
import com.contract.commonlib.base.BaseViewModel
import com.contract.commonlib.http.ext.request
import com.contract.spirit.bean.entity.User
import com.contract.spirit.bean.response.ExchangeResponse
import com.contract.spirit.func.net.rxApi

/**
 * @author: witness
 * created: 2021/9/22
 * desc:
 */
class UserViewModel : BaseViewModel() {
    var exchangeResponse = MutableLiveData<ResultState<ExchangeResponse>>()
    var userResponse = MutableLiveData<ResultState<User>>()
    var exitResponse = MutableLiveData<ResultState<String>>()

    fun getExchangeList() {
        request(
            { rxApi.getExchangeList() },
            exchangeResponse, exchangeResponse.value == null
        )
    }

    fun getUserInfo() {
        request(
            { rxApi.getUserInfo() },
            userResponse, userResponse.value == null
        )
    }


    fun logOut() {
        request(
            { rxApi.exitLogin() },
            exitResponse, isShowDialog = true, loadingMessage = true
        )
    }
}